package com.foreknow.elmboot.controller;

import com.foreknow.elmboot.po.Orders;
import com.foreknow.elmboot.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    /**
     * 生成订单
     * @param orders
     * @return
     */
    @RequestMapping("/createOrders")
    public int createOrders(Orders orders)  {
        return ordersService.createOrdersService(orders);
    }

    /**
     * 根据订单编号查询订单信息，包括所属商家信息，和此订单的所有订单明细信息
     * @param
     * @return
     */
    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Integer orderId) {
        return ordersService.getOrdersByIdService(orderId);
    }

    /**
     * 根据用户编号查询此用户的所有订单信息
     * @param
     * @return
     */
    @RequestMapping("/listOrdersByUserId")
    public List<Orders> listOrdersByUserId(String userId) {
        return ordersService.listOrdersByUserIdService(userId);
    }
}
